home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Files / Next_Dirty_Buffer.bsh < prev    next >
Encoding:
Text File  |  2004-08-29  |  1.0 KB  |  45 lines

  1. /*
  2.  * Next_Dirty_Buffer.bsh - Changes the buffer in
  3.  * the current EditPane to the next dirty buffer, if 
  4.  * there is one.
  5.  *
  6.  * Copyright (C) 2002-2004 Ollie Rutherfurd <oliver@rutherfurd.net>
  7.  *
  8.  * $Id: Next_Dirty_Buffer.bsh,v 1.1 2004/04/09 17:10:15 spestov Exp $
  9.  */
  10.  
  11. void nextDirtyBuffer(View view)
  12. {
  13.     Buffer current = view.getBuffer();
  14.     Buffer b = current.getNext();
  15.     for(int i=0; i < jEdit.getBufferCount()-1; i++)
  16.     {
  17.         // Buffer.getNext() returns null on last
  18.         if(b == null)
  19.             b = jEdit.getFirstBuffer();
  20.         if(b.isDirty())
  21.         {
  22.             view.getEditPane().setBuffer(b);
  23.             return;
  24.         }
  25.         b = b.getNext();    // check next
  26.     }
  27.     // if we get here, we didn't switch
  28.     if(current.isDirty())
  29.         view.getStatus().setMessageAndClear("No other buffers are dirty");
  30.     else
  31.         view.getStatus().setMessageAndClear("No buffers are dirty");
  32. }
  33.  
  34. nextDirtyBuffer(view);
  35.  
  36. /*
  37.  
  38. <listitem>
  39.     <para><filename>Next_Dirty_Buffer.bsh</filename></para>
  40.     <abstract><para>Switches to the next dirty buffer, if there is one.
  41.     </para></abstract>
  42. </listitem>
  43.  
  44. */
  45.